unit Td_Vendor_List;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Td_Trader_List, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxStyles, dxSkinsCore, dxSkinsDefaultPainters,
  dxSkinscxPCPainter, cxDataStorage,
  cxEdit, DB, cxDBData, Menus, DBActns, StdActns, ActnList, ImgList,
  ComCtrls, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
  ExtCtrls, StdCtrls, MisString, cxContainer, cxTextEdit,
  cxMaskEdit, cxDropDownEdit, ToolWin, cxLabel, YBDBCtrlSet,
  cxTreeView, cxCheckBox, cxSplitter, cxButtons,
  cxGridCustomPopupMenu, dxSkinsForm, cxNavigator, cxCustomData, cxFilter,
  cxData, cxGridPopupMenu, MemDS, DBAccess, Uni, System.Actions,
  System.ImageList, RzPanel, cxGridLevel;

type
  TFrmTd_Vendor_List = class(TFrmTd_Trader_List)
    MainDataSetUcloudacc: TWideStringField;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  protected
    function GetOpenWhereSQL: string; override;
    procedure SetUniqueTable; override;
  public
    { Public declarations }
  end;

var
  FrmTd_Vendor_List: TFrmTd_Vendor_List;

implementation



{$R *.dfm}

function TFrmTd_Vendor_List.GetOpenWhereSQL: string;
var
  t_lcode: string;
  ID: integer;
begin
  Result := ' and m.provider=1 ';
  if (PUserInfo.FilID <> 0) then
    Result := Result + ' and filid = ' + IntToStr(puserinfo.FilID);

  Result := Result + ' ' + GetUserRightFilter('td_trader');
  if treType.Selected = nil then Exit;
  t_lcode := pTreeStruc(treType.Selected.Data)^.LCode;
  ID := pTreeStruc(treType.Selected.Data)^.Id;
  case CbbOption.ItemIndex of
    0: begin
        if ID = TMP_ID then
          Result := Result + ' and (A_SubCode is null)'
        else if ID = TMP_ID - 1 then
          Result := Result + ''
        else
          Result := Result + ' and (A_SubCode like (''' + t_lcode + '''+''%''))';
      end;
    1: begin
        if ID = TMP_ID then
          Result := Result + ' and (P_SubCode is null)'
        else if ID = TMP_ID - 1 then
          Result := Result + ''
        else
          Result := Result + ' and (P_SubCode like (''' + t_lcode + '''+''%''))';
      end;
  end;  
end;

procedure TFrmTd_Vendor_List.SetUniqueTable;
begin
  //inherited;
  //MainDataSet.Properties['unique table'].Value := 'td_trader';
end;

procedure TFrmTd_Vendor_List.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  if (self.LookupID <> '') and (P_IsSaveEd) then
  begin
    LookupTableRefresh('td_traderprovider', '');
  end;
end;

end.

